﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Web.Script.Serialization;
using com.igetui.api.openservice.igetui;
using com.igetui.api.openservice.utils;

namespace com.igetui.api.openservice
{
	// Token: 0x0200002B RID: 43
	public class IGtPush : IIGtPush, IIGtQuery, IGtAPN
	{
		// Token: 0x0600047E RID: 1150 RVA: 0x00009CC7 File Offset: 0x00007EC7
		public IGtPush(string domainUrl, string appKey, string masterSecret)
		{
			this._IGtPush(domainUrl, appKey, masterSecret, false);
		}

		// Token: 0x0600047F RID: 1151 RVA: 0x00009CD9 File Offset: 0x00007ED9
		public IGtPush(string appKey, string masterSecret, bool useSSL)
		{
			this._IGtPush(null, appKey, masterSecret, useSSL);
		}

		// Token: 0x06000480 RID: 1152 RVA: 0x00009CEC File Offset: 0x00007EEC
		private void _IGtPush(string domainUrl, string appKey, string masterSecret, bool useSSL)
		{
			this.appKey = appKey;
			this.masterSecret = masterSecret;
			HttpProxy httpProxy = new HttpProxy(new IGtHttpProxy());
			this.httpProxy = httpProxy;
			int defaultConnectionLimit = ServicePointManager.DefaultConnectionLimit;
			if (defaultConnectionLimit < 100)
			{
				ServicePointManager.DefaultConnectionLimit = 1024;
			}
			if (domainUrl == null || domainUrl.Trim().Length == 0)
			{
				this.domailUrlList = GtConfig.getDefaultDomainUrl(useSSL);
			}
			else
			{
				this.domailUrlList = new List<string>();
				this.domailUrlList.Add(domainUrl);
			}
			this.initOSDomain(null);
		}

		// Token: 0x06000481 RID: 1153 RVA: 0x00009DA4 File Offset: 0x00007FA4
		private void initOSDomain(List<string> hosts)
		{
			if (hosts == null || hosts.Count == 0)
			{
				if (!IGtPush.appkeyUrlList.ContainsKey(this.appKey))
				{
					object obj = IGtPush.thisLock;
					lock (obj)
					{
						if (!IGtPush.appkeyUrlList.ContainsKey(this.appKey))
						{
							hosts = this.getOSPushDomainUrlList(this.domailUrlList, this.appKey);
							if (hosts != null && hosts.Count > 0)
							{
								IGtPush.appkeyUrlList.Add(this.appKey, hosts);
							}
						}
					}
				}
				if (IGtPush.appkeyUrlList.ContainsKey(this.appKey))
				{
					hosts = IGtPush.appkeyUrlList[this.appKey];
				}
			}
			if (hosts == null || hosts.Count == 0)
			{
				throw new Exception("Get Push Host Error");
			}
			this.dynamicGetFastest(hosts);
			if (hosts.Count > 1)
			{
				new Timer(new TimerCallback(this.dynamicGetFastest), hosts, 600000, 600000);
			}
		}

		// Token: 0x06000482 RID: 1154 RVA: 0x00009EB4 File Offset: 0x000080B4
		private List<string> getOSPushDomainUrlList(List<string> hosts, string appKey)
		{
			List<string> list = null;
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			dictionary.Add("action", "getOSPushDomailUrlListAction");
			dictionary.Add("appkey", appKey);
			Exception innerException = null;
			foreach (string text in hosts)
			{
				try
				{
					string input = this.httpPostJSON(text, dictionary, false);
					Dictionary<string, object> dictionary2 = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(input);
					if (dictionary2 != null && "ok".Equals(dictionary2["result"]))
					{
						list = this.CastToList((ArrayList)dictionary2["osList"]);
						if (list != null && list.Count > 0)
						{
							break;
						}
					}
				}
				catch (Exception ex)
				{
					innerException = ex;
				}
			}
			if (list == null || list.Count <= 0)
			{
				throw new Exception("Can not get hosts from " + hosts, innerException);
			}
			return list;
		}

		// Token: 0x06000483 RID: 1155 RVA: 0x00009FD0 File Offset: 0x000081D0
		private List<string> CastToList(ArrayList a)
		{
			List<string> list = new List<string>();
			foreach (object obj in a)
			{
				if (obj is string)
				{
					list.Add((string)obj);
				}
			}
			return list;
		}

		// Token: 0x06000484 RID: 1156 RVA: 0x0000A034 File Offset: 0x00008234
		public void dynamicGetFastest(object hostsObj)
		{
			List<string> hosts = IGtPush.appkeyUrlList[this.appKey];
			ApiUrlRespectUtil.setProxy(this.httpProxy);
			this.host = ApiUrlRespectUtil.getFastest(this.appKey, hosts);
		}

		// Token: 0x06000485 RID: 1157 RVA: 0x0000A074 File Offset: 0x00008274
		public bool connect()
		{
			DateTime now = DateTime.Now;
			long num = this.ConvertDateTimeInt(now);
			string md5SignValue = this.getMD5SignValue(new Dictionary<string, object>
			{
				{
					"appkey",
					this.appKey
				},
				{
					"timeStamp",
					num
				},
				{
					"masterSecret",
					this.masterSecret
				}
			});
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			dictionary.Add("action", "connect");
			dictionary.Add("appkey", this.appKey);
			dictionary.Add("timeStamp", num);
			dictionary.Add("sign", md5SignValue);
			string paramData = new JavaScriptSerializer().Serialize(dictionary);
			if (this.httpPost(this.host, paramData, "connect").IndexOf("success") > -1)
			{
				return true;
			}
			throw new Exception("appKey or masterSecret is auth failed.");
		}

		// Token: 0x06000486 RID: 1158 RVA: 0x0000A153 File Offset: 0x00008353
		public IBatch getBatch()
		{
			return new BatchImpl(this.appKey, this);
		}

		// Token: 0x06000487 RID: 1159 RVA: 0x0000A161 File Offset: 0x00008361
		public string pushMessageToSingle(SingleMessage message, Target target)
		{
			return this.pushMessageToSingle(message, target, null);
		}

		// Token: 0x06000488 RID: 1160 RVA: 0x0000A16C File Offset: 0x0000836C
		public string pushMessageToSingle(SingleMessage message, Target target, string requestId)
		{
			if (requestId == null || requestId.Length == 0)
			{
				requestId = Guid.NewGuid().ToString();
			}
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"requestId",
					requestId
				},
				{
					"action",
					"pushMessageToSingleAction"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appId",
					target.appId
				},
				{
					"alias",
					target.alias
				},
				{
					"clientId",
					target.clientId
				},
				{
					"isOffline",
					message.IsOffline
				},
				{
					"offlineExpireTime",
					message.OfflineExpireTime
				},
				{
					"pushNetWorkType",
					message.PushNetWorkType
				},
				{
					"transmissionContent",
					message.Data.getTransmissionContent()
				},
				{
					"type",
					2
				},
				{
					"pushType",
					message.Data.getPushType()
				},
				{
					"clientData",
					Convert.ToBase64String(message.Data.getTransparent().ToByteArray())
				}
			});
		}

		// Token: 0x06000489 RID: 1161 RVA: 0x0000A2B4 File Offset: 0x000084B4
		public string pushAPNMessageToSingle(string appId, string deviceToken, SingleMessage message)
		{
			if (deviceToken == null || deviceToken.Length != 64)
			{
				throw new Exception("deviceToken " + deviceToken + " length must be 64");
			}
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"apnPushToSingleAction"
				},
				{
					"appId",
					appId
				},
				{
					"appkey",
					this.appKey
				},
				{
					"DT",
					deviceToken
				},
				{
					"PI",
					Convert.ToBase64String(message.Data.getPushInfo().ToByteArray())
				}
			});
		}

		// Token: 0x0600048A RID: 1162 RVA: 0x0000A34C File Offset: 0x0000854C
		public string pushMessageToApp(AppMessage message, string taskGroupName)
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			string contentId = this.getContentId(message, taskGroupName);
			dictionary.Add("action", "pushMessageToAppAction");
			dictionary.Add("appkey", this.appKey);
			dictionary.Add("contentId", contentId);
			dictionary.Add("type", 2);
			return this.httpPostJSON(dictionary);
		}

		// Token: 0x0600048B RID: 1163 RVA: 0x0000A3BC File Offset: 0x000085BC
		public string pushMessageToApp(AppMessage message)
		{
			return this.pushMessageToApp(message, null);
		}

		// Token: 0x0600048C RID: 1164 RVA: 0x0000A3C8 File Offset: 0x000085C8
		public string pushMessageToList(string contentId, List<Target> targetList)
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			dictionary.Add("action", "pushMessageToListAction");
			dictionary.Add("appkey", this.appKey);
			dictionary.Add("contentId", contentId);
			bool flag = GtConfig.isPushListNeedDetails();
			dictionary.Add("needDetails", flag);
			bool flag2 = GtConfig.isPushListAsync();
			dictionary.Add("async", flag2);
			int num;
			if (flag2 && !flag)
			{
				num = GtConfig.getAsyncListLimit();
			}
			else
			{
				num = GtConfig.getSyncListLimit();
			}
			if (targetList.Count > num)
			{
				throw new Exception(string.Concat(new object[]
				{
					"target size:",
					targetList.Count,
					" beyond the limit:",
					num
				}));
			}
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			string value = "";
			foreach (Target target in targetList)
			{
				string clientId = target.clientId;
				string alias = target.alias;
				if (!string.IsNullOrWhiteSpace(clientId))
				{
					list.Add(clientId);
				}
				else if (!string.IsNullOrWhiteSpace(alias))
				{
					list2.Add(alias);
				}
				if (string.IsNullOrWhiteSpace(value))
				{
					value = target.appId;
				}
			}
			dictionary.Add("appId", value);
			dictionary.Add("clientIdList", list);
			dictionary.Add("aliasList", list2);
			dictionary.Add("type", 2);
			return this.httpPostJSON(this.host, dictionary, true);
		}

		// Token: 0x0600048D RID: 1165 RVA: 0x0000A57C File Offset: 0x0000877C
		public string pushAPNMessageToList(string appId, string contentId, List<string> deviceTokenlist)
		{
			foreach (string text in deviceTokenlist)
			{
				if (text == null || text.Length != 64)
				{
					throw new Exception("deviceToken length must be 64");
				}
			}
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"apnPushToListAction"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appId",
					appId
				},
				{
					"contentId",
					contentId
				},
				{
					"DTL",
					deviceTokenlist
				},
				{
					"needDetails",
					GtConfig.isPushListNeedDetails()
				},
				{
					"async",
					GtConfig.isPushListAsync()
				}
			});
		}

		// Token: 0x0600048E RID: 1166 RVA: 0x000020A2 File Offset: 0x000002A2
		public void pushMessageToList(ListMessage message, IListProvider listProvider, IPushEventListener listener)
		{
		}

		// Token: 0x0600048F RID: 1167 RVA: 0x0000A658 File Offset: 0x00008858
		public void close()
		{
			this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"close"
				},
				{
					"appkey",
					this.appKey
				}
			});
		}

		// Token: 0x06000490 RID: 1168 RVA: 0x0000A694 File Offset: 0x00008894
		public string getContentId(Message message, string taskGroupName)
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			if (taskGroupName != null && taskGroupName.Trim() != "")
			{
				if (Encoding.UTF8.GetBytes(taskGroupName).Length > 40)
				{
					throw new Exception("TaskGroupName is OverLimit 40");
				}
				dictionary.Add("taskGroupName", taskGroupName);
			}
			dictionary.Add("action", "getContentIdAction");
			dictionary.Add("appkey", this.appKey);
			dictionary.Add("clientData", Convert.ToBase64String(message.Data.getTransparent().ToByteArray()));
			dictionary.Add("transmissionContent", message.Data.getTransmissionContent());
			dictionary.Add("isOffline", message.IsOffline);
			dictionary.Add("offlineExpireTime", message.OfflineExpireTime);
			dictionary.Add("pushNetWorkType", message.PushNetWorkType);
			dictionary.Add("pushType", message.Data.getPushType());
			dictionary.Add("type", 2);
			if (message is AppMessage)
			{
				dictionary.Add("speed", ((AppMessage)message).Speed);
			}
			if (message is ListMessage)
			{
				dictionary.Add("contentType", 1);
			}
			else
			{
				dictionary.Add("contentType", 2);
				dictionary.Add("appIdList", ((AppMessage)message).AppIdList);
				dictionary.Add("phoneTypeList", ((AppMessage)message).PhoneTypeList);
				dictionary.Add("provinceList", ((AppMessage)message).ProvinceList);
				dictionary.Add("tagList", ((AppMessage)message).TagList);
			}
			string input = this.httpPostJSON(dictionary);
			ContentInfo contentInfo = new JavaScriptSerializer().Deserialize<ContentInfo>(input);
			string result = contentInfo.result;
			if (result.IndexOf("ok") > -1)
			{
				return contentInfo.contentId;
			}
			throw new Exception("获取 contentId 失败：" + result);
		}

		// Token: 0x06000491 RID: 1169 RVA: 0x0000A88B File Offset: 0x00008A8B
		public string getContentId(ListMessage message)
		{
			return this.getContentId(message, null);
		}

		// Token: 0x06000492 RID: 1170 RVA: 0x0000A898 File Offset: 0x00008A98
		public string getAPNContentId(string appId, ListMessage message)
		{
			string input = this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"apnGetContentIdAction"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appId",
					appId
				},
				{
					"PI",
					Convert.ToBase64String(message.Data.getPushInfo().ToByteArray())
				}
			});
			ContentInfo contentInfo = new JavaScriptSerializer().Deserialize<ContentInfo>(input);
			string result = contentInfo.result;
			if (result.IndexOf("ok") > -1)
			{
				return contentInfo.contentId;
			}
			throw new Exception("获取 contentId 失败：" + result);
		}

		// Token: 0x06000493 RID: 1171 RVA: 0x0000A938 File Offset: 0x00008B38
		public bool cancelContentId(string contentId)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"cancleContentIdAction"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"contentId",
					contentId
				}
			}).IndexOf("ok") > -1;
		}

		// Token: 0x06000494 RID: 1172 RVA: 0x0000A990 File Offset: 0x00008B90
		public bool stop(string contentId)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"stopTaskAction"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"contentId",
					contentId
				}
			}).IndexOf("ok") > -1;
		}

		// Token: 0x06000495 RID: 1173 RVA: 0x0000A9E8 File Offset: 0x00008BE8
		public string getClientIdStatus(string appId, string clientId)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"getClientIdStatusAction"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appId",
					appId
				},
				{
					"clientId",
					clientId
				}
			});
		}

		// Token: 0x06000496 RID: 1174 RVA: 0x0000AA3C File Offset: 0x00008C3C
		public string setClientTag(string appId, string clientId, List<string> tags)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"setTagAction"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appId",
					appId
				},
				{
					"clientId",
					clientId
				},
				{
					"tagList",
					tags
				}
			});
		}

		// Token: 0x06000497 RID: 1175 RVA: 0x0000AA9C File Offset: 0x00008C9C
		public string getPushResult(string contentId)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"getPushMsgResult"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"taskId",
					contentId
				}
			});
		}

		// Token: 0x06000498 RID: 1176 RVA: 0x0000AAE4 File Offset: 0x00008CE4
		public string getUserTags(string appId, string clientId)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"getUserTags"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appId",
					appId
				},
				{
					"clientId",
					clientId
				}
			});
		}

		// Token: 0x06000499 RID: 1177 RVA: 0x0000AB38 File Offset: 0x00008D38
		public string queryAppPushDataByDate(string appId, string date)
		{
			if (!LangUtils.validateDate(date))
			{
				throw new Exception("DateError|" + date);
			}
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"queryAppPushData"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appId",
					appId
				},
				{
					"date",
					date
				}
			});
		}

		// Token: 0x0600049A RID: 1178 RVA: 0x0000ABA4 File Offset: 0x00008DA4
		public string queryAppUserDataByDate(string appId, string date)
		{
			if (!LangUtils.validateDate(date))
			{
				throw new Exception("DateError|" + date);
			}
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"queryAppUserData"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appId",
					appId
				},
				{
					"date",
					date
				}
			});
		}

		// Token: 0x0600049B RID: 1179 RVA: 0x0000AC10 File Offset: 0x00008E10
		private string httpPostJSON(Dictionary<string, object> postData)
		{
			return this.httpPostJSON(this.host, postData, false);
		}

		// Token: 0x0600049C RID: 1180 RVA: 0x0000AC20 File Offset: 0x00008E20
		public string httpPostJSON(string url, Dictionary<string, object> postData, bool gzip)
		{
			string action = (string)postData["action"];
			if (!postData.ContainsKey("version"))
			{
				postData.Add("version", GtConfig.getSDKVersion());
			}
			string paramData = new JavaScriptSerializer().Serialize(postData);
			string text = this.httpPost(url, paramData, gzip, action);
			if (text != null && !(text == ""))
			{
				if (text.IndexOf("sign_error") > -1)
				{
					if (this.connect())
					{
						return this.httpPost(url, paramData, gzip, action);
					}
				}
				else if (text.IndexOf("domain_error") > -1)
				{
					Dictionary<string, object> dictionary = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(text);
					IGtPush.appkeyUrlList.Add(this.appKey, this.CastToList((ArrayList)dictionary["osList"]));
					this.dynamicGetFastest(null);
					return this.httpPost(this.host, paramData, gzip, action);
				}
				return text;
			}
			if (postData.ContainsKey("requestId"))
			{
				throw new RequestException((string)postData["requestId"], "Http request exception,address is " + url);
			}
			return text;
		}

		// Token: 0x0600049D RID: 1181 RVA: 0x0000AD2D File Offset: 0x00008F2D
		private string httpPost(string postUrl, string paramData, string action)
		{
			return this.httpPost(postUrl, paramData, false, action);
		}

		// Token: 0x0600049E RID: 1182 RVA: 0x0000AD3C File Offset: 0x00008F3C
		private string httpPost(string postUrl, string paramData, bool gzip, string action)
		{
			string text = "";
			int httpTryCount = GtConfig.getHttpTryCount();
			int i = 0;
			string str = null;
			while (i <= httpTryCount)
			{
				HttpWebResponse httpWebResponse = null;
				StreamReader streamReader = null;
				Stream stream = null;
				HttpWebRequest httpWebRequest = null;
				try
				{
					Util.SetCertificatePolicy();
					DateTime now = DateTime.Now;
					long num = this.ConvertDateTimeInt(now);
					httpWebRequest = (HttpWebRequest)WebRequest.Create(new Uri(postUrl));
					WebProxy webProxy = this.httpProxy.getWebProxy();
					if (webProxy != null)
					{
						httpWebRequest.Proxy = webProxy;
					}
					byte[] array = Encoding.UTF8.GetBytes(paramData);
					if (action != null)
					{
						httpWebRequest.Headers.Add("Gt-Action", action);
					}
					if (gzip)
					{
						httpWebRequest.Headers.Add("Content-Encoding", "gzip");
						httpWebRequest.Headers.Add("Accept-Encoding", "gzip");
						array = IGtPush.Zip(paramData);
					}
					httpWebRequest.Method = "POST";
					httpWebRequest.ContentType = "text/html;charset=UTF-8";
					httpWebRequest.Timeout = GtConfig.getHttpConnectionTimeOut();
					httpWebRequest.ReadWriteTimeout = GtConfig.getHttpSoTimeOut();
					httpWebRequest.ContentLength = (long)array.Length;
					httpWebRequest.ProtocolVersion = HttpVersion.Version10;
					httpWebRequest.KeepAlive = true;
					stream = httpWebRequest.GetRequestStream();
					DateTime now2 = DateTime.Now;
					long num2 = this.ConvertDateTimeInt(now2);
					stream.Write(array, 0, array.Length);
					stream.Close();
					httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
					Stream stream2 = httpWebResponse.GetResponseStream();
					if (gzip)
					{
						stream2 = new GZipStream(stream2, CompressionMode.Decompress);
					}
					streamReader = new StreamReader(stream2, Encoding.UTF8);
					text = streamReader.ReadToEnd();
					DateTime now3 = DateTime.Now;
					long num3 = this.ConvertDateTimeInt(now3);
					return text;
				}
				catch (Exception ex)
				{
					i++;
					str = ex.Message;
				}
				finally
				{
					if (streamReader != null)
					{
						streamReader.Close();
						streamReader = null;
					}
					if (httpWebResponse != null)
					{
						httpWebResponse.Close();
						httpWebResponse = null;
					}
					if (stream != null)
					{
						stream.Close();
						stream = null;
					}
					if (httpWebRequest != null)
					{
						httpWebRequest.Abort();
						httpWebRequest = null;
					}
				}
			}
			return text;
		}

		// Token: 0x0600049F RID: 1183 RVA: 0x0000AFBC File Offset: 0x000091BC
		private long ConvertDateTimeInt(DateTime time)
		{
			DateTime d = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, 0));
			return (long)Math.Round((DateTime.Now - d).TotalMilliseconds, MidpointRounding.AwayFromZero);
		}

		// Token: 0x060004A0 RID: 1184 RVA: 0x0000B000 File Offset: 0x00009200
		public string getMD5SignValue(Dictionary<string, object> param)
		{
			string text = "";
			ArrayList arrayList = new ArrayList();
			arrayList.AddRange(param.Keys);
			foreach (object obj in arrayList)
			{
				string key = (string)obj;
				if (param[key].GetType() == typeof(string) || param[key].GetType() == typeof(int) || param[key].GetType() == typeof(long))
				{
					text += param[key];
				}
			}
			byte[] bytes = new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(text));
			text = this.bytearray2string(bytes);
			return text;
		}

		// Token: 0x060004A1 RID: 1185 RVA: 0x0000B0EC File Offset: 0x000092EC
		private string bytearray2string(byte[] bytes)
		{
			string text = "";
			foreach (byte b in bytes)
			{
				text += b.ToString("x2");
			}
			return text;
		}

		// Token: 0x060004A2 RID: 1186 RVA: 0x0000B128 File Offset: 0x00009328
		public string bindAlias(string appId, string alias, string clientId)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"alias_bind"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appid",
					appId
				},
				{
					"alias",
					alias
				},
				{
					"cid",
					clientId
				}
			});
		}

		// Token: 0x060004A3 RID: 1187 RVA: 0x0000B188 File Offset: 0x00009388
		public string bindAlias(string appId, List<Target> targetList)
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
			foreach (Target target in targetList)
			{
				list.Add(new Dictionary<string, string>
				{
					{
						"cid",
						target.clientId
					},
					{
						"alias",
						target.alias
					}
				});
			}
			dictionary.Add("action", "alias_bind_list");
			dictionary.Add("appkey", this.appKey);
			dictionary.Add("appid", appId);
			dictionary.Add("aliaslist", list);
			return this.httpPostJSON(dictionary);
		}

		// Token: 0x060004A4 RID: 1188 RVA: 0x0000B250 File Offset: 0x00009450
		public string queryClientId(string appId, string alias)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"alias_query"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appid",
					appId
				},
				{
					"alias",
					alias
				}
			});
		}

		// Token: 0x060004A5 RID: 1189 RVA: 0x0000B2A4 File Offset: 0x000094A4
		public string queryAlias(string appId, string clientId)
		{
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"alias_query"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"appid",
					appId
				},
				{
					"cid",
					clientId
				}
			});
		}

		// Token: 0x060004A6 RID: 1190 RVA: 0x0000B2F8 File Offset: 0x000094F8
		public string unBindAlias(string appId, string alias, string clientId)
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			dictionary.Add("action", "alias_unbind");
			dictionary.Add("appkey", this.appKey);
			dictionary.Add("appid", appId);
			dictionary.Add("alias", alias);
			if (clientId != null && clientId.Trim() != "")
			{
				dictionary.Add("cid", clientId);
			}
			return this.httpPostJSON(dictionary);
		}

		// Token: 0x060004A7 RID: 1191 RVA: 0x0000B36C File Offset: 0x0000956C
		public string unBindAliasAll(string appId, string alias)
		{
			return this.unBindAlias(appId, alias, null);
		}

		// Token: 0x060004A8 RID: 1192 RVA: 0x0000B378 File Offset: 0x00009578
		public static void CopyTo(Stream src, Stream dest)
		{
			byte[] array = new byte[4096];
			int count;
			while ((count = src.Read(array, 0, array.Length)) != 0)
			{
				dest.Write(array, 0, count);
			}
		}

		// Token: 0x060004A9 RID: 1193 RVA: 0x0000B3AC File Offset: 0x000095AC
		public static byte[] Zip(string str)
		{
			byte[] result;
			using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(str)))
			{
				using (MemoryStream memoryStream2 = new MemoryStream())
				{
					using (GZipStream gzipStream = new GZipStream(memoryStream2, CompressionMode.Compress))
					{
						IGtPush.CopyTo(memoryStream, gzipStream);
					}
					result = memoryStream2.ToArray();
				}
			}
			return result;
		}

		// Token: 0x060004AA RID: 1194 RVA: 0x0000B434 File Offset: 0x00009634
		public static string Unzip(byte[] bytes)
		{
			string @string;
			using (MemoryStream memoryStream = new MemoryStream(bytes))
			{
				using (MemoryStream memoryStream2 = new MemoryStream())
				{
					using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
					{
						IGtPush.CopyTo(gzipStream, memoryStream2);
					}
					@string = Encoding.UTF8.GetString(memoryStream2.ToArray());
				}
			}
			return @string;
		}

		// Token: 0x060004AB RID: 1195 RVA: 0x0000B4BC File Offset: 0x000096BC
		public string pushTagMessage(TagMessage message)
		{
			return this.pushTagMessage(message, null);
		}

		// Token: 0x060004AC RID: 1196 RVA: 0x0000B4C8 File Offset: 0x000096C8
		public string pushTagMessage(TagMessage message, string requestId)
		{
			if (requestId == null || requestId.Length == 0)
			{
				requestId = Guid.NewGuid().ToString();
			}
			return this.httpPostJSON(new Dictionary<string, object>
			{
				{
					"action",
					"pushMessageByTagAction"
				},
				{
					"appkey",
					this.appKey
				},
				{
					"clientData",
					Convert.ToBase64String(message.Data.getTransparent().ToByteArray())
				},
				{
					"transmissionContent",
					message.Data.getTransmissionContent()
				},
				{
					"isOffline",
					message.IsOffline
				},
				{
					"offlineExpireTime",
					message.OfflineExpireTime
				},
				{
					"pushNetWorkType",
					message.PushNetWorkType
				},
				{
					"appIdList",
					message.AppIdList
				},
				{
					"speed",
					message.Speed
				},
				{
					"requestId",
					requestId
				},
				{
					"tag",
					message.Tag
				}
			});
		}

		// Token: 0x040002BB RID: 699
		private static object thisLock = new object();

		// Token: 0x040002BC RID: 700
		private Timer t;

		// Token: 0x040002BD RID: 701
		private string appKey;

		// Token: 0x040002BE RID: 702
		public string host;

		// Token: 0x040002BF RID: 703
		private string masterSecret;

		// Token: 0x040002C1 RID: 705
		private string domainUrl;

		// Token: 0x040002C2 RID: 706
		private static volatile Dictionary<string, List<string>> appkeyUrlList = new Dictionary<string, List<string>>();

		// Token: 0x040002C3 RID: 707
		private List<string> domailUrlList;

		// Token: 0x040002C4 RID: 708
		private HttpProxy httpProxy;
	}
}
